package com.blovesoft.tokenup;

import com.blankj.ALog;
import com.llkj.common.base.app.BaseApp;
import com.llkj.common.http.HttpUtils;
import com.tencent.bugly.crashreport.CrashReport;

import java.util.concurrent.TimeUnit;

import timber.log.Timber;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/5/8
 * desc  :
 */
public class App extends BaseApp {
    @Override
    public void onCreate() {
        super.onCreate();
        ALog.init(this)
                .setLogSwitch(BuildConfig.DEBUG)
                .setConsoleSwitch(BuildConfig.DEBUG)
                .setGlobalTag("common")
                .setConsoleFilter(ALog.V)
                .setStackDeep(1)
                .setStackOffset(5);

        Timber.plant(new Timber.DebugTree() {
            @Override
            protected void log(int priority, String tag, String message, Throwable t) {
                switch (priority) {
                    case ALog.E:
                        ALog.eTag(tag, message);
                        break;
                    case ALog.V:
                        ALog.vTag(tag, message);
                        break;
                    case ALog.D:
                        ALog.dTag(tag, message);
                        break;
                    case ALog.I:
                        ALog.iTag(tag, message);
                        break;
                    case ALog.W:
                        ALog.wTag(tag, message);
                        break;
                    case ALog.A:
                        ALog.aTag(tag, message);
                        break;
                    default:
                        break;
                }
            }

            @Override
            protected boolean isLoggable(String tag, int priority) {
                return BuildConfig.DEBUG;
            }
        });
        //CrashReport.initCrashReport(getApplicationContext(), "742f56e2a4", BuildConfig.DEBUG);
        HttpUtils.init(this);
        HttpUtils.getInstance()
                .isLog(null, BuildConfig.DEBUG)
                .baseUrl("https://www.jealee.com.cn/jiali-interface/")
                .writeTimeout(20, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .connectTimeout(20, TimeUnit.SECONDS)
                .retryCount(3);
    }

}
